package com.ebook.eboo.Dao;

import com.ebook.eboo.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

//JpaRepository<T,ID> 将实体类型和实体的id类型作为参数
public interface userDAO extends JpaRepository<User,Integer> {
    User findByUsername(String username);

    List<User> getAllByUsernameAndPassword(String username, String password);

    User save(User user);

    User getByUsername(String username);

    List<User> getAllBy();

    void deleteUserByUsername(String username);

    @Modifying
    @Query(value = "update User u set u.username=?1,u.password= ?2,u.type=?3 where u.id =?4")
    public int updateById(String username,String password,String type,int id);
}
